# -*- coding: utf-8 -*-
"""
Created on Fri Mar 15 15:14:07 2024

@author: Lenovo
"""

import tkinter as tk
from tkinter import filedialog
from PIL import Image, ImageTk

def select_image(image_number):
    file_path = filedialog.askopenfilename(filetypes=[("Image files", "*.jpg;*.png")])
   
    if file_path:
        image = Image.open(file_path)

        # 限制图片大小为200x200
        image = image.resize((200, 200), Image.ANTIALIAS)

        photo = ImageTk.PhotoImage(image)

        if image_number == 1:
            label1.config(image=photo)
            label1.image = photo
        else:
            label2.config(image=photo)
            label2.image = photo


def apply_function(function_number):
    if function_number == 1:
        
        print("父子")
    elif function_number == 2:
        print("母子")
    elif function_number == 3:
        print("父女")
    elif function_number == 4:
        print("母女")

root = tk.Tk()
root.title("人脸识别比对")

# 图片选择按钮
button1 = tk.Button(root, text="选择图片1", command=lambda: select_image(1))
button1.pack()

button2 = tk.Button(root, text="选择图片2", command=lambda: select_image(2))
button2.pack()

# 显示图片的Label
label1 = tk.Label(root)
label1.pack()

label2 = tk.Label(root)
label2.pack()

# 函数选择按钮
function_label = tk.Label(root, text="选择要执行的函数:")
function_label.pack()

for i in range(1, 5):
    button = tk.Button(root, text=f"函数{i}", command=lambda i=i: apply_function(i))
    button.pack()

root.mainloop()